<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
  <base href="<%=basePath%>">
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <title>用户管理</title>
  <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div id="app">
  <form action="backend/users?action=search" method="post">
  <table border="1">
    <tr>
      <td colspan="8">
        <label>姓名：</label><input type="text" name="userName">
        <label>用户名：</label><input type="text" name="loginName">
        <button id="search" type="submit">搜索</button>
      </td>
    </tr>
  </table>
  </form>
  <table border="1">
    <tr>
      <th>编号</th>
      <th>用户名</th>
      <th>性别</th>
      <th>姓名</th>
      <th>邮箱</th>
      <th>手机</th>
      <th>权限</th>
      <th>操作</th>
    </tr>
    <tbody>
    <c:forEach items="${userList}" var="user">
      <tr>
        <td>${user.id}</td>
        <td>${user.loginName}</td>
        <td>${user.sex}</td>
        <td>${user.userName}</td>
        <td>${user.email}</td>
        <td>${user.mobile}</td>
        <td>${user.type}</td>
        <td class="">
          <a href="#">修改</a>
          <a href="backend/users?action=deleteUser&userId=${user.id}">删除</a>
        </td>
      </tr>
    </c:forEach>
    </tbody>
    <tfoot>
    <tr>
      <td colspan="8" align="center">
        当前第<span class="curPage"><%
      int pageNum =(int) request.getAttribute("pageNum");
      %>
        <%=pageNum%>
      </span>页,共<span class="pageCount"><%
      int pageCount = (int)request.getAttribute("pageCount");
      %>
        <%=pageCount%>
      </span>页
        <a href="backend/users?action=listPage">首页</a>
        <a href="backend/users?action=listPage&page=<%
        int pagePre;
        if (pageNum == 1){
          pagePre=1;
        }else {
          pagePre = pageNum-1;
        }
        %><%=pagePre%>">上一页</a>
        <a href="backend/users?action=listPage&page=<%=pageNum+1%>">下一页</a>
        <a href="backend/users?action=lastPage">尾页</a>
      </td>
    </tr>
    </tfoot>
  </table>
  <script>
  </script>
</div>
</body>
</html>
